﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Willow.Extensions
{
    /// <summary>
    /// 描述：时间扩展
    /// </summary>
    public static class DateTimeExtensions
    {
        /// <summary>
        /// 描述：转换短时间格式
        /// </summary>
        /// <param name="datetime">The datetime.</param>
        /// <returns></returns>
        public static string ToShortDateString(this DateTime? datetime)
        {
            return datetime.HasValue ? datetime.Value.ToString("yyyy-MM-dd") : string.Empty;
        }

        /// <summary>
        /// 描述：转换长时间格式
        /// </summary>
        /// <param name="datetime">The datetime.</param>
        /// <returns></returns>
        public static string ToLongDateString(this DateTime? datetime)
        {
            return datetime.HasValue ? datetime.Value.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty;
        }
    }
}
